<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        // 数组解构
        const arr = ["apple", "banana", "orange"];
        let [a,b,c] = arr;
        let [x,y] = ["peach", "pear"];
        console.log(a,b,c);
        console.log(x,y);
        [x, y = "watermelon"] = [1, 2, 3];
        console.log(x,y);
        let [n1, n2, ...n3] = [4, 5, 6, 7, 8];
        console.log(n1, n2, n3);

        // 对象解构
        const obj = {
            name: "Tom",
            age: 18,
            sex: "male"
        };
        let {name, age, sex} = obj;
        console.log(name, age, sex);
        
        
    </script>
</head>
<body>
    
</body>
</html>